package com.zhou.SingletonMode;

public class SingletonPatternDemo {
    public static void main(String[] args) {
//        SingleObject instance = SingleObject.getInstance();
//        instance.showMessage();

//        new Thread(()->{
//            for (int i = 0; i < 5; i++) {
//                SingletonLazy instance1 = SingletonLazy.getInstance();
//                System.out.println(Thread.currentThread().getName() + instance1.hashCode());
//            }
//        }).start();
//        new Thread(()->{
//            for (int i = 0; i < 5; i++) {
//                SingletonLazy instance1 = SingletonLazy.getInstance();
//                System.out.println(Thread.currentThread().getName() + instance1.hashCode());
//            }
//        }).start();

        //饿汉式
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
//                SingletonStatic instance = SingletonStatic.getInstance();
                SingletonEnum instance = SingletonEnum.INSTANCE;
                instance.show();
//                System.out.println(Thread.currentThread().getName() + ":" + instance.hashCode());
            }).start();
        }


    }
}
